package gui;

import api.list.LinkedList;
import api.Person;

/**
 * @author Ann Raboschuk
 */
public class Controller
{
   private LinkedList<Person> people;
   
   public Controller()
   {
      people = new LinkedList<Person>();
   }
   
   public LinkedList<Person> getPeople()
   {
      return people;
   }
   
   public void setPeople(LinkedList<Person> newPeople)
   {
      people.clear();
      for (int i=0; i<newPeople.size(); i++)
         people.addLast(newPeople.get(i));
   }
   
   public void deletePerson(int index)
   {
      people.delete(index);
   }
   
   public void editPerson(int index, String[] fields)
   {
//      if (fields != null)
//      {
//         Person person = people.get(index);
//         person.setSurname(fields[1]);
//         person.setName(fields[2]);
//         person.setAge(Integer.parseInt(fields[3]));
//         person.setSex(fields[4].charAt(0));
//         person.setEmail(fields[5]);
//         person.setPhone(fields[6]);
//         person.setAddress(fields[7]);
//      }
   }
   
   public void addPerson(String[] fields)
   {
//      if (fields != null)
//      {
//         //String[] phones = fields[6].split(" + ");
//         //Set<>
//         people.addLast(new Person(Long.parseLong(fields[0]), fields[1], fields[2],
//               Integer.parseInt(fields[3]), fields[4].charAt(0), fields[5],
//               fields[6], fields[7]));
//      }
   }
}
